#pragma once

#include "net_conn.h"
#include "sock_callback_filter.h"

class CNetManager	: public c_singleton<CNetManager>
{
public:
	CNetManager(void);
	virtual ~CNetManager(void);

public:
	BOOL Init(ISock_cb_event* pcallback, int nThreadCount = 1);
	BOOL DeInit();
	ISocketConn* Listen(unsigned short sPort, const char* lpszIP);
	ISocketConn* Connect(const char* lpszIP, unsigned short port);
	long settimer(unsigned long milliseconds);
	BOOL killtimer(long timer_id);
	ISocketConn* udp_bind(uint16_t port, const char* lpszIP);

public:
	BOOL OnAddConn(CNetConn* pConn, const int conn_type, struct event_base *base);
	BOOL OnConnBindThread(CNetConn* pConn, struct event_base *base);
	BOOL OnThreadMsg(unsigned int nMsg, void* param1, void* param2);
	CSockCallbackFilter* GetCbfilter();

protected:

protected:
	CSockCallbackFilter	m_cbfilter;
};
